from flask import Flask,request
from flask_sqlalchemy import SQLAlchemy
from config import Config
app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)

class User(db.Model):
    __tablename__='user'
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    name = db.Column(db.String(30),default='')
    sex = db.Column(db.Boolean,default=1)
    score = db.Column(db.Float,default=1)

# db.drop_all()
# db.create_all()


@app.route('/userM',methods=['POST','GET'])
def userM():
    if request.method == 'POST':
        name = request.form.get('name')
        score = request.form.get('score')
        # sex=request.form.get('sex')
        print(name)
        user = User(name=name,score=score,sex=1)
        db.session.add(user)
        db.session.commit()
        return 'ok'
    else:
        users = User.query.all()
        for i in users:
            print(i.name)
            return 'ok'
if __name__ == "__main__":
    app.run()